<?php
defined('BY_JYA') or exit('error');
global $_RQ,$_AR;
$_RQ['op']=$_RQ['op']?$_RQ['op']:'list';
if($_RQ['op']=='list'){
	$params=array('uniacid'=>$_SESSION['uniacid']);
	if($_RQ['title']){
		$params['title like']='%'.trim($_RQ['title']).'%';
		$return['params']['title']=$_RQ['title'];
	}
	$orderby=array();
	$pindex = max(1, intval($_RQ['page']));
	$psize = 10;
	$total='';
	$list=pdo_getslice('jy_kexie_pingjia',$params,array($pindex,$psize),$total,$fields,'','id desc');
	if($list){
		foreach($list as &$item){
			$member=model('core/member')->detail($item['mid'],array('credit1','credit2','mobile','groupid','avatar','nickname'));
			$item['member']=$member;
			if($item['type']==0){
				$item['username']=pdo_getcolumn('jy_kexie_user',array('id'=>$item['user_id'],'uniacid'=>$_SESSION['uniacid']),'name');
			}else{
				$item['username']=pdo_getcolumn('jy_kexie_worker',array('id'=>$item['user_id'],'uniacid'=>$_SESSION['uniacid']),'name');
			}
		}
	}
	$return['list']=$list?$list:array();
	$totalpage=ceil($total/$psize);
	$totalpage=intval($totalpage);
	$return['totalpage'] =$totalpage;
	$return['params']['page'] =$pindex;
	$htmls=array(
		'type'=>'list',
		'tabs'=>array(
			array('op'=>'list','title'=>'评论列表'),
		),
		'list'=>array('data'=>'list','edit'=>false,'del_one'=>false,'delall'=>false,'list'=>array(
			array('name'=>'id','title'=>'ID','type'=>'string'),
			array('name'=>'username','title'=>'姓名','type'=>'string'),
			array('name'=>'member','title'=>'粉丝信息','type'=>'member'),
			array('name'=>'storeid','title'=>'所属学校','type'=>'select','options'=>'stores'),
			array('name'=>'content','title'=>'留言内容','type'=>'string'),
			array('name'=>'createtime','title'=>'创建时间','type'=>'string'),
			array('name'=>'status','title'=>'状态','type'=>'switch','set'=>'set'),
		)),
		'search_one'=>array('name'=>'username','help'=>'客户姓名','add'=>false),
	);
		$return['stores']=pdo_getall('jy_kexie_store',array('uniacid'=>$_SESSION['uniacid']),array('id','title'),'id');

	$return['htmls']=$htmls;
	exi($return);
}
if($_RQ['op']=='edit'){
	$id=intval($_RQ['id']);
	if($id){
		$item=pdo_get('jy_kexie_pingjia',array('id'=>$id,'uniacid'=>$_SESSION['uniacid']));
		$item['createtime']=date('Y/m/d H:i:s',$item['createtime']);
	}else{
		$item=array();
	}
	$return['item']=$item;
	$htmls=array(
		'type'=>'edit',
		'post'=>'post',
		'desc'=>'留言',
		'tabs'=>array(
			array('op'=>'list','title'=>'留言列表'),
			array('op'=>'formlist','title'=>'自定义表单列表'),
		),
		'edit'=>array(
			array('type'=>'copy','title'=>'留言姓名','name'=>'nickname', 'help'=>'' ),
			array('type'=>'copy','title'=>'头像','name'=>'logo', 'help'=>'' ),
			array('type'=>'copy','title'=>'内容','name'=>'content', 'help'=>'' ),
			array('type'=>'copy','title'=>'留言时间','name'=>'createtime', 'help'=>'' ),
			array('type'=>'switch','title'=>'状态','name'=>'status', 'help'=>'' ),
		)
	);
	$return['htmls']=$htmls;
	set_html('framess',$this->menu());
	exi($return);
}
